from LSTM.variableset import EMPath
# 通用

def save_env(code=None, params=None,over_write=False):
    # 数据源的文件名
    # 数据源的训练集合字段
    # 训练/测试的参数 ： 集合长度，time_stamp learn_rate 精确度
    # 检测结果 成功数据，失败数据 阶段统计正确数据 阶段统计错误数据
    # path = EMPath.data_root_path(code=code)
    # f = open(path, 'a')
    # f.write


    pass

LEAN_APP_ID = "4g6XeJMGjVHPvHC9EawfCaJw-gzGzoHsz"
LEAN_APP_KEY = "walTIGMO2b6sXMf5mEQVKruW"

# 上海
CODE_SH = '000001'
# 深圳
CODE_SZ = '399001'
# 中小
CODE_ZX = '399005'
# 创业
CODE_CY = '399006'

BASE_INDEX = ['sh000001', 'sz399001', 'sz399005', 'sz399006']
BASE_INDEX_CODE = [CODE_SH, CODE_SZ, CODE_ZX, CODE_CY]


code = 'code'
date  = 'date'
open = 'open'
close = 'close'
high = 'high'
low = 'low'
volume = 'volume'
label = 'label'

time = 'time'
price = 'price'
volume = 'volume'
amount = 'amount'

datetime = 'datetime'
ktype = 'ktype'
autype = 'autype'

lastupdate_time = 'lastupdate_time'
create_time = 'create_time'

# d : day m: minus 1表示加的偏移量， dm1_close表示 前一天的收盘价 dm1_ajx_price：表示前一天的收盘价与今天收盘价的比较
dm1_close = 'dm1_close'
dm2_close = 'dm2_close'
dm1_ajx_price = 'dm1_ajx_price'
dm2_ajx_price = 'dm2_ajx_price'

# d : day p: plus 1表示加的偏移量， dp1_close表示 后一天的收盘价
dp1_close = 'dp1_close'
dp1_open = 'dp1_open'
dp1_low = 'dp1_low'
dp1_high = 'dp1_high'
dp2_close = 'dp2_close'
dp2_high = 'dp2_high'
dp2_low = 'dp2_low'

dp1_date = 'dp1_date'


BASE_COLUMNS = [code,date,open,close,high,low,volume]

BASE_COLUMNS_LABEL = BASE_COLUMNS + ['label']

real = 'real'
predict = 'predict'
acc = 'acc'

sum_acc = 'sumAcc'
secondLast_acc = 'secondLastAcc'
stock_name = 'stockName'
stock_code = 'code'
sumAcc_top_predict = 'sumAccTopPredict'
sumAcc_least_predict = 'sumAccLeastPredict'
secondLastAcc_top_predict = 'secondLastAccTopPredict'
secondLastAcc_least_predict = 'secondLastAccLeastPredict'



predictMax = 'predictMax'
predictMin = 'predictMin'
# 偏移后最小预测与今天的收盘价的差距
predictMinToCloseAcc = 'predictMinToCloseAcc'
# 偏移后最大预测与今天的收盘价的差距
predictMaxToCloseAcc = 'predictMaxToCloseAcc'


LEAN_STOCK_PREDICT_COLUMNS = [code, stock_name, date, sum_acc, sumAcc_top_predict, sumAcc_least_predict,
                              secondLast_acc, secondLastAcc_top_predict, secondLastAcc_least_predict,predictMax,predictMin]

PREDICT_FILE_COLUMNS = BASE_COLUMNS_LABEL + [real, predict, acc]

PREDICT_FILE_PREFIX = "result_"

DETECT_FILE_PREFIX = "detect_" + PREDICT_FILE_PREFIX


# 数据源
DATA_SOURCE = '600423'
# 训练/测试
TRAIN_STOCK = '600423'
TEST_STOCK = DATA_SOURCE

# 数据源list

#'600583','300169','600302', '600423','002248','601000','600340','300305','000970','300029'
#
DATA_SOURCE_LIST = ['600423', '000661', '600017', '000703', '000069', '000970', '000597', '000877', '600629',
                    '002753']

# ,'300374','300408','002237','300507','300396','002233','600893',
#                     '603018','002709','002582','002458','600326','300449','000762',
#                     '300397','000528','000799','600175','600125','000878','000983',
#                     '601666','000540','600020','600031','600123','600133','600183','600230',
#                     '002061','002008','000797','000338','600547','002230'

# 训练集list
TEST_STOCK_LIST = DATA_SOURCE_LIST

global_dic = {
    code:"代码",
    date:"日期",
    open:"开盘价",
    close:"收盘价",
    high:"最高价",
    volume:"成交量",
    label:"真实值",
    real:"真实值",
    predict:"预测值",
    acc:"准确度(预测值-真实值/预测值)",
    dm1_close: "前1天收盘价",
    dm2_close: "前2天收盘价",
    dm1_ajx_price: "今天对比前1天收盘价涨跌幅",
    dm2_ajx_price: "前2天对比前1天收盘价涨跌幅",

}

# 检测测试结果

# 时间工具常量
FORMATE_YMD = '%Y-%m-%d'
FORMATE_YMD_HM = '%Y-%m-%d %H:%M'
FORMATE_YMD_HMS = '%Y-%m-%d %H:%M:%S'
DAY = 'DAY'
HOUR = 'HOUR'
MIN = 'MIN'
SEC ='SEC'

#指标常量
ID_MA = 'ID_MA'
ID_MACD = 'ID_MACD'
ID_BOLL = 'ID_BOLL'

MA5 = 'MA5'
MA10 = 'MA10'
MA20 = 'MA20'
MA30 = 'MA30'
MA60 = 'MA60'

DIF = 'DIF'
DEA = 'DEA'
# talib中是DIF-DEA，其他地方是 2*(DIF-DEA)
MACD ='MACD'

BOLL_UPPER = 'BOLL_UPPER'
BOLL_MIDDLE = 'BOLL_MIDDLE'
BOLL_LOWER = 'BOLL_LOWER'

import datetime

def format_now(formatter=FORMATE_YMD):
    return datetime.datetime.now().strftime(formatter)

STR_NOW_YMD = format_now(FORMATE_YMD)
STR_NOW_YMD_HM = format_now(FORMATE_YMD_HM)
STR_NOW_YMD_HMS = format_now(FORMATE_YMD_HMS)



"""
indicator result constant
指标计算结果
"""
HIGH2LOW = 'HIGH2LOW'
CLOSE2OPEN = 'CLOSE2OPEN'
ABS_HIGH2LOW = 'ABSHIGH2LOW'
ABS_CLOSE2OPEN = 'ABS_CLOSE2OPEN'

macd = 'macd'
macdsignal = 'macdsignal'
macdhist = 'macdhist'
max = 'max'
adosc = 'adosc'